<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{   
    function __construct($application) 
    {    
        $this->initDb();
        
        $this->initAppVariables();     
        
        $this-> initAjax();
        
        //chama o procedimento do ZF
        parent::__construct($application);
        
    }

    
    public function initDb()
    {
        $config = new Zend_Config_Ini('../application/configs/application.ini','development');
        $db = Zend_Db::factory($config->db->adapter,$config->db);
        
        $registry = Zend_Registry::getInstance();
        $registry->set('db',$db);
        
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        
    }
    
    public function initAppVariables()
    {
        date_default_timezone_set('America/Sao_Paulo');
        
        $registry = Zend_Registry::getInstance();
        $registry->set('tela','home');
        
        Zend_Session::Start();
        
                
      
        /* Esse namespace aparece no nodoController */
//        $currentNod = new Zend_Session_Namespace('currentNod');
//
//        if(isset($_POST['name']))
//        {               
//            $currentNod->name = $_POST['name'];
//            $currentNod->aproved = $_POST['aproved'];
//            $currentNod->nodsFilhos = $_POST['nodsFilhos'];
//            $currentNod->nodsPais = $_POST['nodsPais'];
//
//        }
        
        
    }
    
    public function initAJax()
    {
        $view = new Zend_View();
        $view->addHelperPath('ZendX/JQuery/View/Helper','ZendX_JQuery_View_Helper');
        $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
        Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
        
    }

}

